package com.yiyuwanglu.basecore.web.common;

import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.map.annotate.JsonSerialize;

/**
 * ajax 返回封装类
 * 
 * @author hetaihe
 */
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class ResultMap {

	public enum STATUS {
		SUCCESS, FAILE, ERROR, WARN, NEED_LOGIN
	}

	private String statusCode;
	/**
	 * 状态
	 */
	private STATUS status = STATUS.FAILE;

	/**
	 * 提示语
	 */
	private String message = "";

	/**
	 * 属性
	 */
	private Map<String, Object> attributes = new HashMap<String, Object>();

	/**
	 * 正常成功
	 */
	public static final String STATUS_CODE_SUCCESS = "0000";
	/**
	 * 网络异常
	 */
	public static final String STATUS_CODE_NETWORK_ERROR = "1001";
	/**
	 * 链接超时
	 */
	public static final String STATUS_CODE_TIMEOUT = "1002";
	/**
	 * 未登录
	 */
	public static final String STATUS_CODE_ONLOGIN = "2001";
	/**
	 * 参数缺失
	 */
	public static final String STATUS_CODE_PARAMETERS_LOSE = "2002";
	/**
	 * 参数类型错误
	 */
	public static final String STATUS_CODE_PARAMETERS_TYPE_ERROR = "2003";
	/**
	 * 请求对象不存在
	 */
	public static final String STATUS_CODE_OBJECT_NOFOUNT = "2004";

	/**
	 * 身份认证不通过
	 */
	public static final String STATUS_CODE_AUTHENTICATION_ERROE = "2005";

	/**
	 * 系统错误
	 */
	public static final String STATUS_CODE_SYSTEM_ERROE = "9999";

	/*** 1XXX 网络通讯错误，2xxx业务逻辑错误，3xxx系统抛出异常 ***/
	/*** 20xx公用，21xx用户相关及登录，22xx产品相关 23xx订单 24xx活动相关 25xx收藏 28xx微信 ***/

	public Object getAttribute(String key) {
		return attributes.get(key);
	}

	public void setAttribute(String key, Object value) {
		attributes.put(key, value);
	}

	public STATUS getStatus() {
		return status;
	}

	public void setStatus(STATUS status) {
		this.status = status;
	}

	public String getMessage() {
		return null;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public String getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}

}
